<template>
    <div class="upload-container">
        <el-upload
            :multiple="false"
            :on-success="handleSuccess"
            class="image-uploader"
            drag
            action="/myehr/form/uploadData.action"
        >
            <i class="el-icon-upload" />
            <div class="el-upload__text">将文件拖到此处，或<em>点击上传</em></div>
        </el-upload>
    </div>
</template>

<script>
export default {
    name: 'SingleUpload',
    props: {
        value: {
            type: String,
            default: ''
        }
    },
    data() {
        return {
        }
    },
    computed: {
        imageUrl() {
            return this.value
        }
    },
    methods: {
        rmImage() {
            this.emitInput('')
        },
        emitInput(val) {
            this.$emit('input', val)
        },
        handleSuccess(response, file, fileList) {
            console.log(response, file, fileList)
            this.$emit('success', response)
        },
        beforeUpload() {
        }
    }
}
</script>

<style rel="stylesheet/scss" lang="scss" scoped>
    .upload-container {
        width: 100%;
        position: relative;
        .image-uploader {
            width: 60%;
            float: left;
        }
    }
</style>
